package trefliq.persistence.entity;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 */
@Entity
// These are only useful when testing.  Moving to test file as dynamic queries.
//@NamedQueries( {
//    @NamedQuery(name=Permission.selectAll, query="select o from Permission o")
//    @NamedQuery(name=Permission.countAll, query="select count(o) from Permission o")
//} )
public class Permission implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String userName;
    private Boolean superUser;
    private Boolean canEditInv;
    private Boolean canEditCust;
    private Boolean canManageOrders;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * @param superUser the superUser to set
     */
    public void setSuperUser(Boolean superUser) {
        this.superUser = superUser;
    }

    /**
     * @param canEditInv the canEditInv to set
     */
    public void setCanEditInv(Boolean canEditInv) {
        this.canEditInv = canEditInv;
    }

    /**
     * @param canEditCust the canEditCust to set
     */
    public void setCanEditCust(Boolean canEditCust) {
        this.canEditCust = canEditCust;
    }

    /**
     * @param canManageOrders the canManageOrders to set
     */
    public void setCanManageOrders(Boolean canManageOrders) {
        this.canManageOrders = canManageOrders;
    }

    /**
     * @return the userName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * @return the superUser
     */
    public Boolean getSuperUser() {
        return superUser;
    }

    /**
     * @return the canEditInv
     */
    public Boolean getCanEditInv() {
        return canEditInv;
    }

    /**
     * @return the canEditCust
     */
    public Boolean getCanEditCust() {
        return canEditCust;
    }

    /**
     * @return the canManageOrders
     */
    public Boolean getCanManageOrders() {
        return canManageOrders;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
     /*   private Long id;
        private String userName;
        private Boolean superUser;
        private Boolean canEditInv;
        private Boolean canEditCust;
        private Boolean canManageOrders;
*/
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        boolean equal = false;
        Permission o = (Permission)object;
        if ( object == null || !(object instanceof Permission)) {
            equal = false;
        }
        else if(
            (this.id==null && o.id==null || this.id != null && this.id.equals(o.id)) &&
            (this.userName==null && o.userName==null || this.userName != null && this.userName.equals(o.userName)) &&
            (this.superUser==null && o.superUser==null || this.superUser != null && this.superUser.equals(o.superUser)) &&
            (this.canEditInv==null && o.canEditInv==null || this.canEditInv != null && this.canEditInv.equals(o.canEditInv)) &&
            (this.canEditCust==null && o.canEditCust==null || this.canEditCust != null && this.canEditCust.equals(o.canEditCust)) &&
            (this.canManageOrders==null && o.canManageOrders==null || this.canManageOrders != null && this.canManageOrders.equals(o.canManageOrders)) )
        {
            equal = true;
        }
        
        return equal;
    }

    @Override
    public String toString() {
        return "edu.depaul.se.jpa.basic.Permission[ id=" + id +
                ", userName=["+userName+"]"+
                ", superUser="+superUser+
                ", canEditInv="+canEditInv+
                ", canEditCust="+canEditCust+
                ", canManageOrders="+canManageOrders+
                "]";
    }
}
